package com.young.test.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Order(1)
//@Component
@Aspect
public class LogAspect {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(LogAspect.class);
	
	
	@Before("com.young.test.aop.SystemArchitecture.initOperation()")
	public void beforeInitExecution(JoinPoint joinPoint){
		logger.info("<======== Init ==========>");
		logger.info("This is "+joinPoint.getTarget().getClass().getSimpleName());
	}
	
	@Before("com.young.test.aop.SystemArchitecture.infoOperation() || com.young.test.aop.SystemArchitecture.initOperation()")
	public void beforeInfoExecution(JoinPoint joinPoint){
		logger.info("<======== Begin ==========>");
		logger.info("This is "+joinPoint.getTarget().getClass().getSimpleName());
	}
	@After("com.young.test.aop.SystemArchitecture.infoOperation()")
	public void afterInfoExecution(JoinPoint joinPoint){
		logger.info("<======== End ==========>");
	}
	

}
